package schema

import (
	"entgo.io/ent"
	"entgo.io/ent/dialect/entsql"
	"entgo.io/ent/schema"
	"entgo.io/ent/schema/field"
	"entgo.io/ent/schema/index"
	"private-domain-overseas-service/pkg/status/bizmall"
	"time"
)

type HzMallGoods struct {
	ent.Schema
}

func (HzMallGoods) Fields() []ent.Field {
	return []ent.Field{
		field.Int64("goods_mall_id").Default(0).Comment("商城id"),
		field.String("goods_title").NotEmpty().Comment("商品标题"),
		field.Int64("goods_original_price").Default(0).Comment("原价：单位分"),
		field.Int64("goods_received_price").Default(0).Comment("商品到手价：单位分"),
		field.Int64("goods_commission_rate").Default(0).Comment("商品佣金比例"),
		field.Int64("goods_commission").Default(0).Comment("商品佣金,返利金额"),
		field.String("goods_buy_url").NotEmpty().Comment("商品购买链接"),
		field.String("goods_image").NotEmpty().Comment("商品封面图"),
		field.Text("goods_desc").Optional().Comment("商品详情"),
		field.Int64("goods_status").Default(bizmall.On).Comment("商品启用状态：1启用，2禁用"),
		field.Int64("goods_created_at").Comment("商品添加时间，用于排序支持修改以实现排序功能"),
		field.Int64("created_at").Immutable().Default(time.Now().Unix()).Comment("创建时间"),
		field.Int64("update_at").Default(time.Now().Unix()).Comment("更新时间"),
		field.Int64("delete_at").Optional().Comment("删除时间"),
	}
}

// Indexes of the Street.
func (HzMallGoods) Indexes() []ent.Index {
	return []ent.Index{
		index.Fields("goods_status"),
		index.Fields("goods_created_at"),
	}
}

func (HzMallGoods) Annotations() []schema.Annotation {
	return []schema.Annotation{
		entsql.WithComments(true),
		schema.Comment("商城推荐商品表"),
	}
}
